﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.BandedGrid;
using System.Data;
using UniMana.Data;

namespace UniMana.Win.Training
{
    public partial class RprScore_Transcripts : DevExpress.XtraReports.UI.XtraReport
    {
        public RprScore_Transcripts(string level,string subject, string deparment,
            string term, string schoolyear,DataTable dt,AdvBandedGridView gv,string major,
            string subjectClassID,string credits = null )
        {
            InitializeComponent();
            xrlMajor.Text = "NGÀNH: " + major.ToUpper();
            xrlLevel.Text = "HỆ: " + level.ToUpper();
            xrlSubject.Text = "Môn học: " + subject.ToUpper();
            Training_Subject_ClassInfo infoSubjectClass = new Training_Subject_ClassInfo(subjectClassID);
            if (infoSubjectClass.Properties.Yearly == true)
            {
                xrlCredits.Text = "Số ĐVHT: " + credits;   
            }
            else
            {
                xrlCredits.Text = "Số tín chỉ: " + credits;
            }
            xrlDepartment.Text = "KHOA: " + deparment;
            xrlTerm.Text += term;
            xrlSchoolyear.Text = "NĂM HỌC: " + schoolyear;
            xrlSubjectClassID.Text = "MÃ LỚP HỌC PHẦN: " + subjectClassID;
            gridControl1.DataSource = dt;
            AdvBandedGridView gvCopy = new AdvBandedGridView();
            for (int j = 0; j < gv.Columns.Count; j++)
            {
                BandedGridColumn grdColumn = gv.Columns[j];
                gvCopy.Columns.Add(grdColumn);

            }

            #region [oldCode]
            //for (int i = gv.Bands.Count; i < 0; i--)
            //{
            //    GridBand gb = gv.Bands[i];
            //    gb.AppearanceHeader.BackColor = Color.Transparent;
            //    gvCopy.Bands.Add(gb);
            //    //gvCopy.Bands[i].AppearanceHeader.BackColor = Color.Transparent;
            //}
            //for (int j = 0; j < gvCopy.Bands.Count; j++)
            //{
            //    gvCopy.Bands[j].AppearanceHeader.BackColor = Color.Transparent;
            //}
            #endregion

            for (int i = 0; i < gvCopy.Columns.Count; i++)
            {
                gvCopy.Columns[i].AppearanceHeader.BackColor = Color.Transparent;
                gvCopy.Columns[i].OwnerBand.AppearanceHeader.BackColor = Color.Transparent;
                gvCopy.Columns[i].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                gvCopy.Columns[i].AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                //gvCopy.Columns[i].AppearanceCell.he
            }

            gridControl1.MainView = gvCopy;

            #region [OldCode]
            //gridView1.AppearancePrint.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            //gridView1.AppearancePrint.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            //gridView1.OptionsView.AllowHtmlDrawHeaders = true;
            //gridView1.Appearance.HeaderPanel.Options.UseTextOptions = true;
            //gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            //gridView1.OptionsPrint.UsePrintStyles = true;

            //gridView1.OptionsView.AllowHtmlDrawHeaders = true;
            //gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            //gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            //gridView1.Appearance.ViewCaption.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            //gridView1.Appearance.HeaderPanel.TextOptions.Trimming = DevExpress.Utils.Trimming.None;
            //for(int l=0;l<gridView1.Columns.Count;l++)
            //{
            //    gridView1.Columns[l].OptionsColumn.AllowSize = false;
            //    gridView1.Columns[l].OptionsColumn.FixedWidth = true;
            //}
            //gridView1.AppearancePrint.HeaderPanel.Options.UseTextOptions = true;
            //gridView1.AppearancePrint.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            //gridView1.OptionsPrint.UsePrintStyles = true;
            //gridView1.Columns[1].OptionsColumn.
            #endregion
        }
        public void RptClose()
        {
            this.gridControl1.MainView = null;
        }
    }
}
